<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Promise</title>
</head>

<body>
  <script>
    let isTrue = true;
    const p = new Promise((resolve, reject) => {
      if (isTrue) {
        resolve('成功了')
      } else {
        reject('失败了')
      }
    })
    p.then((res) => {
      console.log(1)
    }, (err) => {
      console.log(err)
    })

    setTimeout(() => {
      console.log("2")
    }, 10);
    
    // Promise.prototype.then()
    // console.log(p.then((res) => {
    //   console.log(res)
    // }, (err) => {
    //   console.log(err)
    // }))
    // Promise {<pending>}
    // [[Prototype]]: Promise
    // [[PromiseState]]: "fulfilled"
    // [[PromiseResult]]: undefined
    //失败了

    // const fn=() => {
    //   console.log('fn')
    //   return 'ces'
    // }
    // console.log(fn())
  </script>
</body>

</html>